<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <title>乐优商城--我的订单</title>
    <link rel="icon" href="assets/img/favicon.ico">

    <link rel="stylesheet" type="text/css" href="css/webbase.css" />
    <link rel="stylesheet" type="text/css" href="css/pages-seckillOrder.css" />
</head>

<body>

<!-- 头部栏位 -->
<!--页面顶部，由js动态加载-->
<script type="text/javascript" src="plugins/jquery/jquery.min.js"></script>
<div id="nav-bottom"></div>
<script type="text/javascript">$("#nav-bottom").load("top.html");</script>

<script type="text/javascript" src="js/plugins/jquery/jquery.min.js"></script>
<script type="text/javascript">
    $(function(){
        $("#service").hover(function(){
            $(".service").show();
        },function(){
            $(".service").hide();
        });
        $("#shopcar").hover(function(){
            $("#shopcarlist").show();
        },function(){
            $("#shopcarlist").hide();
        });

    })
</script>
<script type="text/javascript" src="js/plugins/jquery.easing/jquery.easing.min.js"></script>
<script type="text/javascript" src="js/plugins/sui/sui.min.js"></script>
<script type="text/javascript" src="js/plugins/jquery-placeholder/jquery.placeholder.min.js"></script>
<script type="text/javascript" src="js/widget/nav.js"></script>
<script src="./js/vue/vue.js"></script>
<script src="./js/vue/vuetify.js"></script>
<script src="./js/axios.min.js"></script>
<script src="./js/common.js"></script>
</body>
<div id="userHomeApp">
    <!--header-->
    <div id="account">
        <div class="py-container">
            <div class="yui3-g home">
                <!--左侧列表-->
                <div class="yui3-u-1-6 list">

                    <div class="person-info">
                        <div class="person-photo"><img src="img/_/photo.png" alt=""></div>
                        <div class="person-account">
                            <span class="name">{{userName}}</span>
                            <span class="safe"><a href="#">退出登录 </a></span>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                    <div class="list-items">
                        <dl>
                            <dt><i>·</i> 订单中心</dt>
                            <dd ><a href="home-index.html"  class="list-active" >我的订单</a></dd>
                            <dd><a href="#" @click.prevent="pagination.status = 1,pagination.page = 1,pagination.rows = 5,pagination.key = ''" :class="{'list-active' : pagination.status == 1}">待付款</a></dd>
                            <dd><a href="#" @click.prevent="pagination.status = 2,pagination.page = 1,pagination.rows = 5,pagination.key = ''" :class="{'list-active' : pagination.status == 2}">待发货</a></dd>
                            <dd><a href="#" @click.prevent="pagination.status = 3,pagination.page = 1,pagination.rows = 5,pagination.key = ''" :class="{'list-active' : pagination.status == 3}">待收货</a></dd>
                            <dd><a href="#" @click.prevent="pagination.status = 4,pagination.page = 1,pagination.rows = 5,pagination.key = ''" :class="{'list-active' : pagination.status == 4}">待评价</a></dd>
                        </dl>
                        <dl>
                            <dt><i>·</i> 我的中心</dt>
                            <dd><a href="home-person-collect.html">我的收藏</a></dd>
                            <dd><a href="home-person-footmark.html">我的足迹</a></dd>
                        </dl>
                        <dl>
                            <dt><i>·</i> 物流消息</dt>
                        </dl>
                        <dl>
                            <dt><i>·</i> 设置</dt>
                            <dd><a href="home-setting-info.html">个人信息</a></dd>
                            <dd><a href="home-setting-address.html"  >地址管理</a></dd>
                            <dd><a href="home-setting-safe.html" >安全管理</a></dd>
                        </dl>
                    </div>
                </div>
                <!--右侧主内容-->
                <div class="yui3-u-5-6 order-pay">
                    <div class="body">
                        <div class="table-title">
                            <table class="sui-table  order-table">
                                <tr>
                                    <thead>
                                    <th width="35%">宝贝</th>
                                    <th width="5%">单价</th>
                                    <th width="5%">数量</th>
                                    <th width="8%">商品操作</th>
                                    <th width="10%">实付款</th>
                                    <th width="10%">交易状态</th>
                                    <th width="10%">交易操作</th>
                                    </thead>
                                </tr>
                            </table>
                        </div>
                        <div class="choose-order">
                            <div v-if="pagination.status == 1">
                                <label  data-toggle="checkbox" class="checkbox-pretty checked">
                                    <input type="checkbox" checked="checked"><span>全选</span>
                                </label>
                                <a href=""  class="sui-btn btn-info btn-bordered hepay-btn">合并付款</a>
                            </div>
                            <div v-else>
                                <input type="text" @keyup.enter="search" v-model="searchKey"><button value="搜索" @click="search">搜索</button>
                            </div>
                        </div>
                        <div class="order-detail">
                            <div class="orders" v-for="(order,i) in orders" :key="i">
                                <!--order-->
                                <div class="choose-title" >
                                    <label data-toggle="checkbox" class="checkbox-pretty ">
                                        <input type="checkbox" checked="checked"><span>{{order.createTime}}　订单编号：{{order.orderId}}  店铺：哇哈哈 <a>和我联系</a></span>
                                    </label>
                                    <a class="sui-btn btn-info share-btn">分享</a>
                                </div>
                                <table class="sui-table table-bordered order-datatable" v-for="(orderDetail,j) in order.orderDetails" :key="j" v-if="order.status ==1">
                                    <tbody>
                                    <tr >
                                        <td width="35%">
                                            <div class="typographic"><img :src="orderDetail.image ? orderDetail.image : ''" height="100" width="100"/>
                                                <a href="#" class="block-text">{{orderDetail.title}}</a>
                                                <span class="guige" v-for="(v,k,index) in JSON.parse(orderDetail.ownSpec)" :key="index">{{k}}：{{v}}</span>
                                            </div>
                                        </td>
                                        <td width="5%" class="center">
                                            <ul class="unstyled">
                                                <!--<li class="o-price">¥599.00</li>-->
                                                <li>¥{{ly.formatPrice(orderDetail.price)}}</li>
                                            </ul>
                                        </td>
                                        <td width="5%" class="center">{{orderDetail.num}}</td>
                                        <td width="8%" class="center">

                                        </td>
                                        <td width="10%" class="center" >
                                            <ul class="unstyled">
                                                <li>¥{{ly.formatPrice(orderDetail.price * orderDetail.num)}}</li>
                                                <li>（含运费：￥0.00）</li>
                                            </ul>
                                        </td>
                                        <td width="10%" class="center">
                                            <ul class="unstyled">
                                                <li >等待买家付款</li>
                                                <li><a href="home-orderDetail.html" class="btn">订单详情 </a></li>
                                            </ul>
                                        </td>
                                        <td width="10%" class="center">
                                            <ul class="unstyled">
                                                <li><a href="#" class="sui-btn btn-info">立即付款</a></li>
                                                <li>取消订单</li>
                                            </ul>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                                <table class="sui-table table-bordered order-datatable" v-for="(orderDetail,j) in order.orderDetails" :key="j" v-else-if="order.status ==2">
                                    <tbody>
                                    <tr >
                                        <td width="35%">
                                            <div class="typographic"><img :src="orderDetail.image ? orderDetail.image : ''" height="100" width="100"/>
                                                <a href="#" class="block-text">{{orderDetail.title}}</a>
                                                <span class="guige" v-for="(v,k,index) in JSON.parse(orderDetail.ownSpec)" :key="index">{{k}}：{{v}}</span>
                                            </div>
                                        </td>
                                        <td width="5%" class="center">
                                            <ul class="unstyled">
                                                <!--<li class="o-price">¥599.00</li>-->
                                                <li>¥{{ly.formatPrice(orderDetail.price)}}</li>
                                            </ul>
                                        </td>
                                        <td width="5%" class="center">{{orderDetail.num}}</td>
                                        <td width="8%" class="center">

                                        </td>
                                        <td width="10%" class="center" >
                                            <ul class="unstyled">
                                                <li>¥{{ly.formatPrice(orderDetail.price * orderDetail.num)}}</li>
                                                <li>（含运费：￥0.00）</li>
                                            </ul>
                                        </td>
                                        <td width="10%" class="center">
                                            <ul class="unstyled">
                                                <li >买家已付款</li>
                                                <li><a href="home-orderDetail.html" class="btn">订单详情 </a></li>
                                            </ul>
                                        </td>
                                        <td width="10%" class="center">
                                            <ul class="unstyled">
                                                <li><a href="#" class="sui-btn btn-info">提醒发货</a></li>
                                            </ul>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                                <table class="sui-table table-bordered order-datatable" v-for="(orderDetail,j) in order.orderDetails" :key="j" v-else-if="order.status ==3">
                                    <tbody>
                                    <tr >
                                        <td width="35%">
                                            <div class="typographic"><img :src="orderDetail.image ? orderDetail.image : ''" height="100" width="100"/>
                                                <a href="#" class="block-text">{{orderDetail.title}}</a>
                                                <span class="guige" v-for="(v,k,index) in JSON.parse(orderDetail.ownSpec)" :key="index">{{k}}：{{v}}</span>
                                            </div>
                                        </td>
                                        <td width="5%" class="center">
                                            <ul class="unstyled">
                                                <!--<li class="o-price">¥599.00</li>-->
                                                <li>¥{{ly.formatPrice(orderDetail.price)}}</li>
                                            </ul>
                                        </td>
                                        <td width="5%" class="center">{{orderDetail.num}}</td>
                                        <td width="8%" class="center">

                                        </td>
                                        <td width="10%" class="center" >
                                            <ul class="unstyled">
                                                <li>¥{{ly.formatPrice(orderDetail.price * orderDetail.num)}}</li>
                                                <li>（含运费：￥0.00）</li>
                                            </ul>
                                        </td>
                                        <td width="10%" class="center">
                                            <ul class="unstyled">
                                                <li >买家已发货</li>
                                                <li><a href="home-orderDetail.html" class="btn">订单详情 </a></li>
                                            </ul>
                                        </td>
                                        <td width="10%" class="center">
                                            <ul class="unstyled">
                                                <li><a href="#" class="sui-btn btn-info">确认发货</a></li>
                                            </ul>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                                <table class="sui-table table-bordered order-datatable" v-for="(orderDetail,j) in order.orderDetails" :key="j" v-else-if="order.status ==4">
                                    <tbody>
                                    <tr >
                                        <td width="35%">
                                            <div class="typographic"><img :src="orderDetail.image ? orderDetail.image : ''" height="100" width="100"/>
                                                <a href="#" class="block-text">{{orderDetail.title}}</a>
                                                <span class="guige" v-for="(v,k,index) in JSON.parse(orderDetail.ownSpec)" :key="index">{{k}}：{{v}}</span>
                                            </div>
                                        </td>
                                        <td width="5%" class="center">
                                            <ul class="unstyled">
                                                <!--<li class="o-price">¥599.00</li>-->
                                                <li>¥{{ly.formatPrice(orderDetail.price)}}</li>
                                            </ul>
                                        </td>
                                        <td width="5%" class="center">{{orderDetail.num}}</td>
                                        <td width="8%" class="center">

                                        </td>
                                        <td width="10%" class="center" >
                                            <ul class="unstyled">
                                                <li>¥{{ly.formatPrice(orderDetail.price * orderDetail.num)}}</li>
                                                <li>（含运费：￥0.00）</li>
                                            </ul>
                                        </td>
                                        <td width="10%" class="center">
                                            <ul class="unstyled">
                                                <li >交易成功</li>
                                                <li><a href="home-orderDetail.html" class="btn">订单详情 </a></li>
                                            </ul>
                                        </td>
                                        <td width="10%" class="center">
                                            <ul class="unstyled">
                                                <li><a href="#" class="sui-btn btn-info">立即评价</a></li>
                                            </ul>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                            <div class="choose-order">
                                <div class="sui-pagination pagination-large top-pages">
                                    <ul>
                                        <li :class="{prev:true,disabled:pagination.page == 1}">
                                            <a @click="prevPage" href="javascript:void(0)">«上一页</a>
                                        </li>
                                        <li class="dotted" v-if="pagination.page > 2 && totalPage != 3"><span>...</span></li>
                                        <li :class="{active:index(i) == pagination.page}" v-for="i in Math.min(3,totalPage)" :key="i">
                                            <a href="#" @click.prevent="pagination.page = index(i)">{{index(i)}}</a>
                                        </li>
                                        <li class="dotted" v-if="pagination.page < totalPage-1"><span>...</span></li>
                                        <li :class="{next:true,disabled:pagination.page == totalPage}">
                                            <a @click="nextPage" href="javascript:void(0)">下一页»</a>
                                        </li>
                                    </ul>
                                    <div><span>共{{totalPage}}页&nbsp;</span><span>
                                            到
                                            <input type="text" class="page-num" v-model="jumpPage"   @keyup.enter="pagination.page = jumpPage"><button class="page-confirm" @click="pagination.page = jumpPage">确定</button>
                                            页</span></div>
                                </div>
                            </div>

                            <div class="clearfix"></div>
                        </div>

                        <div class="like-title">
                            <div class="mt">
                                <span class="fl"><strong>热卖单品</strong></span>
                            </div>
                        </div>
                        <div class="like-list">
                            <ul class="yui3-g">
                                <li class="yui3-u-1-4">
                                    <div class="list-wrap">
                                        <div class="p-img">
                                            <img src="img/_/itemlike01.png" />
                                        </div>
                                        <div class="attr">
                                            <em>DELL戴尔Ins 15MR-7528SS 15英寸 银色 笔记本</em>
                                        </div>
                                        <div class="price">
                                            <strong>
                                                <em>¥</em>
                                                <i>3699.00</i>
                                            </strong>
                                        </div>
                                        <div class="commit">
                                            <i class="command">已有6人评价</i>
                                        </div>
                                    </div>
                                </li>
                                <li class="yui3-u-1-4">
                                    <div class="list-wrap">
                                        <div class="p-img">
                                            <img src="img/_/itemlike02.png" />
                                        </div>
                                        <div class="attr">
                                            <em>Apple苹果iPhone 6s/6s Plus 16G 64G 128G</em>
                                        </div>
                                        <div class="price">
                                            <strong>
                                                <em>¥</em>
                                                <i>4388.00</i>
                                            </strong>
                                        </div>
                                        <div class="commit">
                                            <i class="command">已有700人评价</i>
                                        </div>
                                    </div>
                                </li>
                                <li class="yui3-u-1-4">
                                    <div class="list-wrap">
                                        <div class="p-img">
                                            <img src="img/_/itemlike03.png" />
                                        </div>
                                        <div class="attr">
                                            <em>DELL戴尔Ins 15MR-7528SS 15英寸 银色 笔记本</em>
                                        </div>
                                        <div class="price">
                                            <strong>
                                                <em>¥</em>
                                                <i>4088.00</i>
                                            </strong>
                                        </div>
                                        <div class="commit">
                                            <i class="command">已有700人评价</i>
                                        </div>
                                    </div>
                                </li>
                                <li class="yui3-u-1-4">
                                    <div class="list-wrap">
                                        <div class="p-img">
                                            <img src="img/_/itemlike04.png" />
                                        </div>
                                        <div class="attr">
                                            <em>DELL戴尔Ins 15MR-7528SS 15英寸 银色 笔记本</em>
                                        </div>
                                        <div class="price">
                                            <strong>
                                                <em>¥</em>
                                                <i>4088.00</i>
                                            </strong>
                                        </div>
                                        <div class="commit">
                                            <i class="command">已有700人评价</i>
                                        </div>
                                    </div>
                                </li>

                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 底部栏位 -->
<!--页面底部，由js动态加载-->
<div class="clearfix footer"></div>
<script type="text/javascript">$(".footer").load("foot.html");</script>
<!--页面底部END-->
<script>
    var userHomeVM = new Vue({
        el:"#userHomeApp",
        data: {
            ly,
            orders: [],
            pagination: {
                page: 1,
                rows: 5,
                status: "",
                key: ""
            },
            totalPage: 0,
            total: 0,
            userName: "",
            jumpPage: "", // 跳转页面
            searchKey: ""
        },
        methods:{
            loadOrders() {
                ly.http.get("/order/order/list",{
                    params:{
                        page: this.pagination.page,
                        rows: this.pagination.rows,
                        status: this.pagination.status,
                        key: this.pagination.key
                    }
                }).then(({data}) => {
                    this.totalPage = data.totalPage;
                    this.total = data.total;
                    this.orders = data.items;
                });
            },
            index(i) {
                if (this.pagination.page <= 2) {
                    return i;
                } else if (this.pagination.page >= this.totalPage - 1) {
                    return this.totalPage - 3 + i;
                } else {
                    return this.pagination.page - 2 + i;
                }
            },
            prevPage() {
                if (this.pagination.page > 1) {
                    this.pagination.page--;
                }
            },
            nextPage() {
                if (this.pagination.page < this.totalPage) {
                    this.pagination.page++;
                }
            },
            search() {
                this.pagination.key = this.searchKey;
                this.pagination.page = 1;
                this.pagination.rows = 5;
            }
        },
        created(){
            // 将请求参数转为对象
            const pagination = ly.parse(location.search.substring(1));
            // 对page进行初始化
            pagination.page = pagination.page ? parseInt(pagination.page) : 1;
            // 对rows进行初始化
            pagination.rows = pagination.rows ? parseInt(pagination.rows) : 5;
            // 对status进行初始化
            pagination.status = pagination.status ? parseInt(pagination.status) : "";
            // 对key进行初始化
            pagination.key = pagination.key ? pagination.key : "";
            this.pagination = pagination;
            this.loadOrders();
            ly.verify().then(res => {
                this.userName = res.data.username
            }).catch(() => {
                return;
            });

        },
        watch:{
            pagination:{
                deep: true,
                handler(val,old) {
                    if (!old.key && !old.status && old.page == 1) {
                        // 如果旧的pagination的key为空，并且status为空,并且old的page ==1 ，证明是第一次
                        return;
                    }
                   /* if (old.status != val.status) {
                        // 如果是status变化，需要对page，rows，以及key清空还原
                        this.pagination.key = "";
                        this.pagination.page = 1;
                        this.pagination.rows = 5;
                    }*/
                   /* if (old.key != val.key) {
                        // 如果是key变化，需要对page，rows还原
                        this.pagination.page = 1;
                        this.pagination.rows = 5;
                    }*/

                    // 把search对象变成请求参数，拼接在url路径
                    window.location.href = "http://www.leyou.com/home-index.html?" + ly.stringify(val);
                }
            }
        },
        components:{
            lyTop: () => import('/js/pages/top.js'),
        }
    });
</script>

</html>